#include <am.h>
#include <npc.h>

void __am_timer_init() {
}

void __am_timer_uptime(AM_TIMER_UPTIME_T *uptime) {
  if(uptime == NULL)
    return;
  uint32_t *p = (uint32_t *)uptime;
  *p      = inl(UPTIME_ADDR);
  *(p+1)  = inl(UPTIME_ADDR + 4);
}

void __am_timer_rtc(AM_TIMER_RTC_T *rtc) {
  // union {
  //   struct {
  //     uint32_t low;
  //     uint32_t high;
  //   } us32;
  //   uint64_t us64;
  // } us;
  // us.us32.high = inl(RTC_ADDR);
  // us.us32.low = inl(RTC_ADDR + 4);
  // uint64_t s = us.us64 / 1000000;
  // rtc->second = s % 60;
  // rtc->minute = (s % 3600) / 60;
  // rtc->hour   = (s % (24 * 3600)) / 3600;
  rtc->second = 0;
  rtc->minute = 0;
  rtc->hour   = 0;
  rtc->day    = 0;
  rtc->month  = 0;
  rtc->year   = 1900;
}